// KetonalConfigWindow.cpp: implementation of the KetonalConfigWindow class.
//
//////////////////////////////////////////////////////////////////////
#include "FileUpload.h"
#include "KetonalSettingsComponent.h"
#include "KetonalConfigWindow.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

KetonalConfigWindow::KetonalConfigWindow(KetonalSettingsComponent *_p, const File f)
{
	parent = _p;
	bubbleMessage = new BubbleMessageComponent();
	bubbleMessage->addToDesktop (0);

	addAndMakeVisible (configComponent = new KetonalConfigComponent(f));
	closeButton = LookAndFeel::getDefaultLookAndFeel().createDocumentWindowButton (DocumentWindow::closeButton);
	addAndMakeVisible (closeButton);
	closeButton->addButtonListener (this);

	setVisible (true);
	setAlwaysOnTop (true);
	addToDesktop (ComponentPeer::windowIsTemporary);
	setBounds (parent->getScreenX(), parent->getScreenY()+parent->getHeight()+3, 256, 128);

	String m;
	StringArray k = FileUpload::getPossibleProtocols();

	m = T("Supported protocols: \n");
	for (int x=0; x<k.size(); x++)
	{
		m << k[x] << T("\n");
	}

	k.clear();
	bubbleMessage->showAt (this, m, 8000);
}

KetonalConfigWindow::~KetonalConfigWindow()
{
	deleteAndZero (configComponent);
	deleteAndZero (bubbleMessage);
	deleteAndZero (closeButton);
}

void KetonalConfigWindow::resized()
{
	closeButton->setBounds (236,4,16,16);
}

void KetonalConfigWindow::buttonClicked (Button *btn)
{
	if (btn == closeButton)
	{
		parent->closeConfig();
		delete this;
	}
}